$(function () {
    let username = sessionStorage.getItem("username")
    if (username === null) {
        location.href = '/period/web/html/login.html';
    }
})

//ajax属于异步调用  和同步           异步属于随机执行
function myAjax(url, data, type) {
    let result = null;
    data.loginName = sessionStorage.getItem("username");
    //console.log(data);
    $.ajax({
        url: 'http://localhost:8080' + url,
        data: data,
        type: type,
        dataType: 'json',
        async: false,
        success: function (res) {
            if (res.code === 500) {
                xadmin.open('请求错误', '/period/web/html/error.html', 300, 200)
                return result;
            }
            result = res;
        }
    });
    return result;
}